Skip to content

Defensively thread path into NestedTypeVarSubstitutionRepairVisitor - #1683

Merged
msridhar merged 1 commit into
masterfrom
preserve-paths-through-nested-type-repair
Aug 8, 2026
Merged

Defensively thread path into NestedTypeVarSubstitutionRepairVisitor#1683
msridhar merged 1 commit into
masterfrom
preserve-paths-through-nested-type-repair

Conversation

@msridhar

@msridhar msridhar commented Aug 7, 2026

Copy link
Copy Markdown
Collaborator

This addresses step 2 of #1680 (comment)

Summary by CodeRabbit

  • Bug Fixes
    • Improved nullability analysis for generic method invocations, including nested type arguments.
    • Ensured analysis uses the correct source location when repairing nested nullability information.
    • Improved consistency of argument type checking in generic method calls.
    • Reduced incorrect or inconsistent nullability warnings in code that combines generic methods with nested type parameters.

@msridhar

msridhar commented Aug 7, 2026

Copy link
Copy Markdown
Collaborator Author

This change is part of the following stack:

Change managed by git-spice.

@msridhar
msridhar requested a review from yuxincs August 7, 2026 16:57
@coderabbitai

coderabbitai Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 6f584c59-dca7-40e0-b93d-0f82b69653fd

📥 Commits

Reviewing files that changed from the base of the PR and between 9b2b56b and d0a83c4.

📒 Files selected for processing (1)
  • nullaway/src/main/java/com/uber/nullaway/generics/GenericsChecks.java

Walkthrough

GenericsChecks now passes the invocation TreePath into nested nullability repair. NestedTypeVarSubstitutionRepairVisitor uses the path to initialize VisitorState when available. It falls back to the existing state path when the invocation path is null. Actual argument paths derive from the visitor state's current path.

Possibly related PRs

  • uber/NullAway#1286: Both PRs modify path-aware generic type inference and nested type-variable substitution.
  • uber/NullAway#1309: Both PRs propagate invocation TreePath context through generic method inference.
  • uber/NullAway#1574: This PR extends related generic type-repair logic with invocation-path propagation.

Suggested reviewers: yuxincs, lazaroclapp

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the main change: threading the invocation path into NestedTypeVarSubstitutionRepairVisitor.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch preserve-paths-through-nested-type-repair

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
nullaway/src/main/java/com/uber/nullaway/generics/NestedTypeVarSubstitutionRepairVisitor.java (1)

97-109: 📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win

Add Javadoc for the private constructor.

This constructor now selects the invocation path and rebuilds VisitorState. Document the nullable invocationPath parameter, the fallback to state.getPath(), and that the stored path ends at invocationTree.

As per coding guidelines, **/src/main/**/*.java: Add Javadoc for every non-trivial method, including private methods.

Proposed Javadoc
+  /**
+   * Creates a repair visitor with a state path that ends at {`@code` invocationTree}.
+   *
+   * <p>If {`@code` invocationPath} is {`@code` null}, derives the path from {`@code` state.getPath()}.
+   */
  private NestedTypeVarSubstitutionRepairVisitor(
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@nullaway/src/main/java/com/uber/nullaway/generics/NestedTypeVarSubstitutionRepairVisitor.java`
around lines 97 - 109, Add Javadoc immediately above the private constructor
containing the shown initialization, documenting the nullable invocationPath
parameter, its fallback to state.getPath(), and that the rebuilt VisitorState
path ends at invocationTree.

Source: Coding guidelines

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In
`@nullaway/src/main/java/com/uber/nullaway/generics/NestedTypeVarSubstitutionRepairVisitor.java`:
- Around line 97-109: Add Javadoc immediately above the private constructor
containing the shown initialization, documenting the nullable invocationPath
parameter, its fallback to state.getPath(), and that the rebuilt VisitorState
path ends at invocationTree.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: c0fc3711-f555-40fb-9526-f5d952180119

📥 Commits

Reviewing files that changed from the base of the PR and between b7342a6 and 9b2b56b.

📒 Files selected for processing (2)
  • nullaway/src/main/java/com/uber/nullaway/generics/GenericsChecks.java
  • nullaway/src/main/java/com/uber/nullaway/generics/NestedTypeVarSubstitutionRepairVisitor.java

@codecov

codecov Bot commented Aug 7, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 87.77%. Comparing base (9904903) to head (6fc043b).

Additional details and impacted files
@@            Coverage Diff            @@
##             master    #1683   +/-   ##
=========================================
  Coverage     87.77%   87.77%           
- Complexity     3142     3143    +1     
=========================================
  Files           109      109           
  Lines         10606    10608    +2     
  Branches       2150     2151    +1     
=========================================
+ Hits           9309     9311    +2     
  Misses          611      611           
  Partials        686      686           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@msridhar
msridhar enabled auto-merge (squash) August 7, 2026 18:01
@msridhar msridhar mentioned this pull request Aug 7, 2026
@msridhar
msridhar force-pushed the preserve-paths-through-nested-type-repair branch from 9b2b56b to d0a83c4 Compare August 7, 2026 22:51
@msridhar
msridhar force-pushed the preserve-paths-through-nested-type-repair branch from d0a83c4 to 6fc043b Compare August 7, 2026 23:46
@msridhar
msridhar merged commit 73d8de0 into master Aug 8, 2026
14 checks passed
@msridhar
msridhar deleted the preserve-paths-through-nested-type-repair branch August 8, 2026 02:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants